package org.gd.hellojaxb.other;

import org.gd.hellojaxb.utils.Marshall;
import org.gd.hellojaxb.utils.MarshallProperties;
import org.gd.hellojaxb.utils.UnMarshall;

import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.*;

@XmlRootElement(name="c")
public class CDATATest {

    private String bio;

    @XmlElement(name = "arg")
    public void setBio(String bio) {
        this.bio = bio;
    }

    public String getBio() {
        return bio;
    }

    @Override
    public String toString() {
        return "CDATATest{" +
                "bio='" + bio + '\'' +
                '}';
    }

    public static void main(String...str) throws JAXBException {
        /*String xml = "<c>" +
                "<arg>" +
                "<[![CDATA[<html>EMAIL</html>]]>" +
                "</arg>" +
                "</c>";
        CDATATest test = UnMarshall.unmarshal(
                xml,
                CDATATest.class);*/

        CDATATest test = new CDATATest();
        test.setBio("<[![CDATA[<html>EMAIL</html>]]>");
        String xml = Marshall.getInstance().marshal(
                test,
                MarshallProperties.FORMATTED_OUTPUT,
                MarshallProperties.CDATA
        );
        System.out.println(xml);
    }

}
